package TOOL;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

public class DialogRe extends AlertDialog.Builder {
public Window mWindow;
public AlertDialog nAD;
public Context mContext;

    public DialogRe(Context context, int layout) {
        super(context);
        mContext = context;
        setView(layout);
    }

    public DialogRe(Context context, int layout, boolean bool) {
        super(context);
        mContext = context;
        setView(layout);
        setCancelable(bool);
    }

    public DialogRe(Context context, String title, String msg) {
        super(context);
        mContext = context;
        setTitle(title);
        setMessage(msg);
    }

    public DialogRe(Context context, String title, String msg, boolean bool) {
        super(context);
        mContext = context;
        setTitle(title);
        setMessage(msg);
        setCancelable(bool);
    }

     public void Init(){
        nAD = show();
        mWindow = nAD.getWindow();
        mWindow.setGravity(Gravity.CENTER);
     }


    public void buttonOK(String s) {
        setPositiveButton(s, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                sureEvent();
            }
        });
    }

    public void buttonCancle(String s) {
        setNegativeButton(s, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                cancleEvent();
            }
        });
    }

    public void buttonUnknown(String s) {
        setNeutralButton(s, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                unknownEvent();
            }
        });
    }

    public void sureEvent() {
        // TODO Implement this function
    }

    public void cancleEvent() {

    }

    public void unknownEvent(){

    }

    public void close(){
        nAD.dismiss();
    }

    public  void DialogShow(){
        nAD.show();
    }

    public void keyBoardGetFocouse(){
        mWindow.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
        mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }
}
